home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PowerMacOr68K.c
-
- Contains: This snippet shows how to determine whether you are running on
- a Power Macintosh or on a 680x0 Macintosh. It also provides the
- method for determine exactly which type of processor is running.
- This works around an off-by-one error with gestaltNativeCPUType.
-
- Written by: Virginia (Ginny) McCulloh
-
- Copyright: Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/9/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
- Updated to list G3 750
-
-
- */
-
-
- #include <Gestalt.h>
- #include <stdio.h>
-
- Boolean hasPowerPCArch(void);
-
- void main()
- {
- OSErr err;
- long feature;
-
- /* First we will check the system architecture. */
- if (hasPowerPCArch()) /* It's a Power Macintosh of some sort */
- {
- /* What kind of Power Macintosh processor is this. */
- err = Gestalt (gestaltNativeCPUtype, &feature);
- if (0x100 & feature)
- {
- if (gestaltCPU601 == feature)
- printf( "\nThis puppy is a PowerMac with a 601 processor!");
- else if (gestaltCPU603 == feature)
- printf( "\nThis puppy is a PowerMac with a 603 processor!");
- else if (gestaltCPU604 == feature)
- printf( "\nThis puppy is a PowerMac with a 604 processor!");
- else if (gestaltCPU750 == feature)
- printf( "\nThis puppy is a PowerMac with a G3 processor aka PPC 750!");
- else
- printf( "\nThis must be some sort of PowerMac. I think.");
- }
- }
- else /* This is some sort of 68K machine */
- {
- err = Gestalt ( gestaltProcessorType, &feature );
- if (gestalt68040 == feature)
- printf( "\nThis is a 68040." );
- else if (gestalt68030 == feature)
- printf( "\nThis is a 68030.");
- else if (gestalt68020 == feature)
- printf( "\nThis is a 68020.");
- else if (gestalt68010 == feature)
- printf( "\nThis is a 68010.");
- else if (gestalt68000 == feature)
- printf( "\nThis is a 68000.");
- else
- printf( "\nI don't know what this is.");
-
- }
- }
-
- Boolean hasPowerPCArch()
- /*
- Gestalt will return an error if the gestaltSysArchitecture selector is
- not recognized by the System, so we can assume this is a 68K machine.
- Otherwise, this function returns true for a Power Mac and false for
- a 68K Mac.
- */
- {
- long gestaltResult;
-
- if (Gestalt(gestaltSysArchitecture, &gestaltResult))
- return(false);
- else
- return(gestaltResult == gestaltPowerPC);
- }
-